/**
 * 基础错误类
 */
export class BaseError extends Error {
  constructor(
    public message: string,
    public status: number = 500,
    public code: string = 'INTERNAL_ERROR'
  ) {
    super(message);
    this.name = this.constructor.name;
    Error.captureStackTrace(this, this.constructor);
  }
}

/**
 * 400 错误 - 请求参数错误
 */
export class BadRequestError extends BaseError {
  constructor(message: string = 'Bad Request') {
    super(message, 400, 'BAD_REQUEST');
  }
}

/**
 * 401 错误 - 未授权
 */
export class UnauthorizedError extends BaseError {
  constructor(message: string = 'Unauthorized') {
    super(message, 401, 'UNAUTHORIZED');
  }
}

/**
 * 403 错误 - 禁止访问
 */
export class ForbiddenError extends BaseError {
  constructor(message: string = 'Forbidden') {
    super(message, 403, 'FORBIDDEN');
  }
}

/**
 * 404 错误 - 资源未找到
 */
export class NotFoundError extends BaseError {
  constructor(message: string = 'Not Found') {
    super(message, 404, 'NOT_FOUND');
  }
}

/**
 * 409 错误 - 业务冲突
 */
export class ConflictError extends BaseError {
  constructor(message: string = 'Conflict') {
    super(message, 409, 'CONFLICT');
  }
}

/**
 * 流程相关错误
 */
export class FlowError extends BaseError {
  constructor(message: string) {
    super(message, 400, 'FLOW_ERROR');
  }
} 